package day03;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/4/10
 */

//求3.1415926...=(1-1/3+1/5-1/7+1/9..........)*4

public class Test4 {
    public static void main(String[] args) {
        int n=1000000000;
        double pi=0.0;
        for(int i=1; i<=n; i++){
            double p=(i%2==0)? -1 : 1;
            double q=p/(2*i-1);
            pi+=q;
        }
        pi*=4;
        System.out.println(pi);
    }
}
